package xm.components.table
{
	
	/**
	 * <br> 클래스 설명 : </br>
	 * @author 김정환
	 */	
	public class TR
	{
		
		//-----------------------------------------------------------------------------------
		// public vars
		//-----------------------------------------------------------------------------------
		
		/**
		 * x : Number - table로부터 논리적인 x 상대좌표.  
		 */		
		public var x : Number = 0;
		
		/**
		 * y : Number - table로부터 논리적인 y 상대좌표.  
		 */		
		public var y : Number = 0;
		
		/**
		 * width : Number - 논리적인 width값.  
		 */		
		public var width : Number = 0;
		
		/**
		 * height : Number - 논리적인 height값.  
		 */		
		public var height : Number = 0;
		
		/**
		 * td List vector
		 */		
		public var tdList : Vector.<TD> = new Vector.<TD>();
		
		
		/** 보더 - 상단 색상 **/
		public var borderTopColor : uint = 0xffffff;
		
		/** 보더 - 상단 알파 **/
		public var borderTopAlpha : Number = 1;
		
		/** 보더 - 상단 두께 **/
		public var borderTopThickness : Number = 0;
		
		
		/** 배경색상 **/
		public var backgroundColor : uint = 0xffffff;
		
		/** 배경알파 **/
		public var backgroundAlpha : Number = 0;
		
		//-----------------------------------------------------------------------------------
		// protected / internal vars
		//-----------------------------------------------------------------------------------
		
		
		
		
		//-----------------------------------------------------------------------------------
		// private vars
		//-----------------------------------------------------------------------------------
		
		
		
		
		//-----------------------------------------------------------------------------------
		// public functions
		//-----------------------------------------------------------------------------------
		
		/**
		 * constructor 
		 */	
		public function TR()
		{
			
		}
		
		
		
		/**
		 * commitProperties
		 */		
		public function commitProperties():void
		{
			
		}
		
		
		
		/**
		 * updateDisplayList
		 */		
		public function updateDisplayList():void
		{
			
		}
		
		
		
		
		
		/**
		 * td 삽입.
		 * @param td : TD
		 */		
		public function addTD( tr:TD ):void
		{
			this.tdList.push( tr );
		}
		
		/**
		 * @param td
		 * @param index
		 */		
		public function addTDAt( td:TD, index:int ):void
		{
			if( tdList.length > index )
			{
				tdList.splice( index, 0, td ); 
			}
		}
		
		/**
		 * @param td : TD - 제거.
		 */		
		public function removeTD( td:TD ):void
		{
			if( tdList.indexOf( td ) > -1 )
			{
				tdList.splice( tdList.indexOf( td ) , 1 );
			}
		}
		
		/**
		 * @param td : TD - 제거.
		 */		
		public function removeTDAt( index:int ):void
		{
			if( tdList.length > index )
			{
				tdList.splice( index , 1 );
			}
		}
		
		
		
		
		
		/**
		 * @param width
		 * @param parentTR
		 * @param autoAdd
		 * @param borderRightAlpha
		 * @param borderRightColor
		 * @param borderRightThickness
		 * @return TD
		 */		
		public function makeTD( width : Number,
								padding : Array = null,
								backgroundColor : uint = 0xffffff,
								backgroundAlpha : Number = 0,
								borderLeftThickness : Number = 1,
								borderLeftColor : Number = 0xcccccc,
								borderLeftAlpha : Number = 1,
								autoAdd : Boolean = true ):TD
		{
			var td : TD;
			
			td = new TD();
			td.width = width;
			td.padding = padding;
			td.backgroundColor = backgroundColor;
			td.backgroundAlpha = backgroundAlpha;
			td.borderLeftThickness = borderLeftThickness;
			td.borderLeftColor = borderLeftColor;
			td.borderLeftAlpha = borderLeftAlpha;
			if( autoAdd ) this.addTD( td );
			
			return td;
		}
		
		
		
		//-----------------------------------------------------------------------------------
		// life cycle functions
		//-----------------------------------------------------------------------------------
		
		
		/**
		 * destroy
		 */		
		public function destroy():void
		{
			
			var i:int, len:int;
			
			
			
			// 속성제거.
			x = NaN;
			y = NaN;
			
			width = NaN;
			height = NaN;
			
			borderTopColor = 0;
			borderTopAlpha = NaN;
			borderTopThickness = NaN;
			
			backgroundColor = 0;
			backgroundAlpha = NaN;
			
			
			
			//td 제거.
			i=0;
			len=tdList.length;
			
			while( i<len )
			{
				tdList[ i ].destroy();
				delete tdList[ i ];
				++i;
			}
			
			tdList = null;
			
		}
		
		//-----------------------------------------------------------------------------------
		// setter / getter
		//-----------------------------------------------------------------------------------
		
		
		
		//-----------------------------------------------------------------------------------
		// protected functions
		//-----------------------------------------------------------------------------------
		
		
		
		//-----------------------------------------------------------------------------------
		// internal functions
		//-----------------------------------------------------------------------------------
		
		
		
		
		//-----------------------------------------------------------------------------------
		// private functions
		//-----------------------------------------------------------------------------------
		
		
		
		//-----------------------------------------------------------------------------------
		// event handler
		//-----------------------------------------------------------------------------------
		
		
		
		
		
		
		
		
		
	}
}